﻿<%@ Page Title="Car Offers - Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Welcome to Car Offers in ASP.NET!
    </h2>
    <p>
        <asp:HyperLink NavigateUrl="~/AddOffer.aspx" Text="Add offer" runat="server" />
    </p>
    <p>
        <asp:ValidationSummary ID="CarsFilterValidationSummary" runat="server" CssClass="failureNotification" 
            ValidationGroup="CarsFilterValidationGroup"/>    
        <asp:Panel ID="notificationMsgPanel" CssClass="failureNotification" Visible="false" runat="server">
            <asp:BulletedList ID="notificationMsgList" runat="server">
            </asp:BulletedList>
        </asp:Panel>
    </p>
    <p>
	    <div class="filterInfo">
	    <fieldset class="register">			
		    <legend>Filter</legend>				
		    <p>
                <span>Brand</span>
			    <asp:DropDownList ID="brandsDropDown" runat="server" DataValueField="Id" DataTextField="Name" OnSelectedIndexChanged="Brands_IndexChanged" AutoPostBack="true" >
                </asp:DropDownList>
                <asp:CustomValidator ID="BrandsValidator" runat="server" ControlToValidate="brandsDropDown" CssClass="failureNotification"
                    ErrorMessage="Please select valid brand." ToolTip="Please select valid brand." ValidationGroup="CarsFilterValidationGroup"
                    OnServerValidate="Id_ServerValidate">X</asp:CustomValidator>
                <span>Model</span>
                <asp:DropDownList ID="modelsDropDown" runat="server" DataValueField="Id" DataTextField="Name" >
                    <asp:ListItem Value="-1">-- Select model --</asp:ListItem>
                </asp:DropDownList>
                <asp:CustomValidator ID="modelsValidator" runat="server" ControlToValidate="modelsDropDown" CssClass="failureNotification"
                    ErrorMessage="Please select valid model." ToolTip="Please select valid model." ValidationGroup="CarsFilterValidationGroup"
                    OnServerValidate="Id_ServerValidate">X</asp:CustomValidator>
		    </p>
		    <p>
                <span style="display:block;">Make year</span>
			    <span>From&nbsp;&nbsp;&nbsp;</span>
                <asp:TextBox ID="yearDownTxt" runat="server" />
                <asp:RequiredFieldValidator ID="yearDownRequired" runat="server" ControlToValidate="yearDownTxt" 
                        CssClass="failureNotification" ErrorMessage="From year value is required." ToolTip="From year value is required." 
                        ValidationGroup="CarsFilterValidationGroup">*</asp:RequiredFieldValidator>
                <asp:CustomValidator ID="fromYearValidator" runat="server" ControlToValidate="yearDownTxt" CssClass="failureNotification"
                    ErrorMessage="From year value is not valid number." ToolTip="From year value is not valid number." ValidationGroup="CarsFilterValidationGroup"
                    OnServerValidate="Year_ServerValidate">X</asp:CustomValidator>
			    <span>&nbsp;To&nbsp;&nbsp;&nbsp;</span>
                <asp:TextBox ID="yearUpTxt" runat="server" />
                <asp:RequiredFieldValidator ID="yearUpRequired" runat="server" ControlToValidate="yearUpTxt" 
                        CssClass="failureNotification" ErrorMessage="To year value is required." ToolTip="To year value is required." 
                        ValidationGroup="CarsFilterValidationGroup">*</asp:RequiredFieldValidator>
                <asp:CustomValidator ID="toYearValidator" runat="server" ControlToValidate="yearUpTxt" CssClass="failureNotification"
                    ErrorMessage="To year value is not valid number." ToolTip="To year value is not valid number." ValidationGroup="CarsFilterValidationGroup"
                    OnServerValidate="Year_ServerValidate">X</asp:CustomValidator>
		    </p>
		    <p>
			    <span>Minimum price &#36;</span>
                <asp:TextBox ID="priceDownTxt" runat="server" />
                <asp:RequiredFieldValidator ID="MinPriceRequired" runat="server" ControlToValidate="priceDownTxt" 
                    CssClass="failureNotification" ErrorMessage="Minimum price value is required." ToolTip="Minimum price value is required." 
                    ValidationGroup="CarsFilterValidationGroup">*</asp:RequiredFieldValidator>
                <asp:CustomValidator ID="minPriceValidator" runat="server" ControlToValidate="priceDownTxt" CssClass="failureNotification"
                    ErrorMessage="Minimum price is not valid number." ToolTip="Minimum price is not valid number." ValidationGroup="CarsFilterValidationGroup"
                    OnServerValidate="Price_ServerValidate">X</asp:CustomValidator>                                
                <span>Maximum price &#36;</span>
                <asp:TextBox ID="priceUpTxt" runat="server" />
                <asp:RequiredFieldValidator ID="MaxPriceRequired" runat="server" ControlToValidate="priceUpTxt" 
                    CssClass="failureNotification" ErrorMessage="Maximum price value is required." ToolTip="Maximum price value is required." 
                    ValidationGroup="CarsFilterValidationGroup">*</asp:RequiredFieldValidator>
                <asp:CustomValidator ID="maxPriceValidator" runat="server" ControlToValidate="priceUpTxt" CssClass="failureNotification"
                    ErrorMessage="Maximum price is not valid number." ToolTip="Maximum price is not valid number." ValidationGroup="CarsFilterValidationGroup"
                    OnServerValidate="Price_ServerValidate">X</asp:CustomValidator>  
		    </p>
	    </fieldset>
	    <p class="submitButton">
            <asp:Button ID="searchCarOffersBtn" Text="Search" runat="server" OnClick="SearchCarOffers_OnClick"
            ValidationGroup="CarsFilterValidationGroup" />
	    </p>
	    </div>							    
    </p>
    <p>
        <asp:Label ID="testLbl" runat="server" />
    </p>
    <p>
        <asp:GridView ID="carOffersGrid" AllowPaging="false" AutoGenerateColumns="false" CssClass="nicetable" 
            AlternatingRowStyle-CssClass="alternaterow" runat="server" 
            OnRowEditing="EditCarOfferEventHandler_RowEditing"
            OnPageIndexChanging="CarOffersGridView_PageIndexChanging" >
            <Columns>
                <asp:BoundField HeaderText="Brand" DataField="Brand" />
                <asp:BoundField HeaderText="Model" DataField="Model" />
                <asp:BoundField HeaderText="Year" DataField="Year" />
                <asp:BoundField HeaderText="Price &#36;" DataField="Price" />
                <asp:BoundField HeaderText="Contact" DataField="Contact" />
            </Columns>
        </asp:GridView>
    </p>
</asp:Content>
